home *** CD-ROM | disk | FTP | other *** search
/ Chip: Hang es video / CHIP_ZENESZERKESZTO_2005.ISO / audio_3 / visual / robotfunk / setup.exe / {app} / main.dxr / Internal_17.ls < prev    next >
Encoding:
Text File  |  2003-11-19  |  7.3 KB  |  292 lines

  1. global black, white
  2.  
  3. on EvilTopo srcimg, someLevel, someInverse
  4.   if someLevel < 1 then
  5.     someLevel = 127
  6.   end if
  7.   img1 = srcimg.duplicate()
  8.   img1.fill(img1.rect, rgb(someLevel, someLevel, someLevel))
  9.   if someInverse then
  10.     img1.copyPixels(srcimg, img1.rect, img1.rect, [#ink: 39])
  11.   else
  12.     img1.copyPixels(srcimg, img1.rect, img1.rect, [#ink: 37])
  13.   end if
  14.   return img1
  15. end
  16.  
  17. on contrast srcimg, someLevel
  18.   someLevel = someLevel / 2.54999999999999982
  19.   tRect = srcimg.rect
  20.   img1 = srcimg.duplicate()
  21.   img2 = srcimg.duplicate()
  22.   img3 = srcimg.duplicate()
  23.   img1.fill(tRect, rgb(128, 128, 128))
  24.   img2.fill(tRect, rgb(127, 127, 127))
  25.   img2.copyPixels(srcimg, tRect, tRect, [#ink: 39])
  26.   img2.copyPixels(img1, tRect, tRect, [#ink: 33])
  27.   img2.copyPixels(img2, tRect, tRect, [#ink: 4])
  28.   img1.fill(tRect, rgb(128, 128, 128))
  29.   img1.copyPixels(srcimg, tRect, tRect, [#ink: 37])
  30.   img3.fill(tRect, rgb(128, 128, 128))
  31.   img1.copyPixels(img3, tRect, tRect, [#ink: 35])
  32.   useLevel = someLevel
  33.   if (someLevel mod 100) > 0 then
  34.     img3.fill(tRect, rgb(0, 0, 0))
  35.     img3.copyPixels(img1, tRect, tRect, [#blend: useLevel])
  36.     img1 = img3.duplicate()
  37.     img3.fill(tRect, rgb(0, 0, 0))
  38.     img3.copyPixels(img2, tRect, tRect, [#blend: useLevel])
  39.     img2 = img3.duplicate()
  40.   end if
  41.   img3 = srcimg.duplicate()
  42.   img3.copyPixels(img2, tRect, tRect, [#ink: 35])
  43.   img3.copyPixels(img1, tRect, tRect, [#ink: 33])
  44.   return img3
  45. end
  46.  
  47. on channel srcimg, somecolor, someInverse
  48.   overimg = srcimg.duplicate()
  49.   case somecolor of
  50.     "red", "green", "blue":
  51.       thisInk = 1
  52.       thisColor = rgb(0, 0, 0)
  53.     otherwise:
  54.       thisInk = 5
  55.       thisColor = rgb(255, 255, 255)
  56.   end case
  57.   hexColor = NameToHex(somecolor)
  58.   if someInverse then
  59.     if thisInk = 1 then
  60.       thisInk = 5
  61.     else
  62.       thisInk = 1
  63.     end if
  64.   end if
  65.   overimg.fill(overimg.rect, hexColor)
  66.   overimg.copyPixels(srcimg, overimg.rect, overimg.rect, [#ink: thisInk, #color: thisColor])
  67.   return overimg
  68. end
  69.  
  70. on colorSaturate srcimg, somecolor
  71.   overimg = srcimg.duplicate()
  72.   case somecolor of
  73.     "red", "green", "blue":
  74.       thisInk = 5
  75.       thisColor = rgb(255, 255, 255)
  76.     otherwise:
  77.       thisInk = 1
  78.       thisColor = rgb(0, 0, 0)
  79.   end case
  80.   hexColor = NameToHex(somecolor)
  81.   overimg.fill(overimg.rect, hexColor)
  82.   overimg.copyPixels(srcimg, overimg.rect, overimg.rect, [#ink: thisInk, #color: thisColor])
  83.   return overimg
  84. end
  85.  
  86. on EvilColorFlop srcimg, somecolor, someColor2, somePsycho
  87.   overimg = srcimg.duplicate()
  88.   if somePsycho then
  89.     thisInk = 5
  90.   else
  91.     thisInk = 1
  92.   end if
  93.   hexColor = NameToHex(somecolor)
  94.   thisColor = NameToHex(someColor2)
  95.   overimg.fill(overimg.rect, hexColor)
  96.   overimg.copyPixels(srcimg, overimg.rect, overimg.rect, [#ink: thisInk, #color: thisColor])
  97.   return overimg
  98. end
  99.  
  100. on NameToHex somecolor
  101.   case somecolor of
  102.     "red":
  103.       hexColor = rgb(255, 0, 0)
  104.     "green":
  105.       hexColor = rgb(0, 255, 0)
  106.     "blue":
  107.       hexColor = rgb(0, 0, 255)
  108.     "cyan":
  109.       hexColor = rgb(0, 255, 255)
  110.     "magenta":
  111.       hexColor = rgb(255, 0, 255)
  112.     "yellow":
  113.       hexColor = rgb(255, 255, 0)
  114.     otherwise:
  115.       hexColor = rgb(0, 0, 0)
  116.   end case
  117.   return hexColor
  118. end
  119.  
  120. on duotone srcimg, somecolor, someColor2, someFlop
  121.   Img = EvilColorFlop(srcimg, somecolor, someColor2, someFlop)
  122.   return Img
  123. end
  124.  
  125. on psycho srcimg, somecolor, someColor2, someFlop, someInverse
  126.   Img = EvilColorFlop(srcimg, somecolor, someColor2, someFlop)
  127.   if someFlop then
  128.     Img.copyPixels(srcimg, srcimg.rect, srcimg.rect, [#ink: 37])
  129.   else
  130.     Img.copyPixels(srcimg, srcimg.rect, srcimg.rect, [#ink: 39])
  131.   end if
  132.   if someInverse then
  133.     Img.copyPixels(Img, srcimg.rect, srcimg.rect, [#ink: 4])
  134.   end if
  135.   return Img
  136. end
  137.  
  138. on invert srcimg
  139.   Img = srcimg.duplicate()
  140.   Img.copyPixels(Img, srcimg.rect, srcimg.rect, [#ink: 4])
  141.   return Img
  142. end
  143.  
  144. on saturation srcimg, lvl
  145.   if srcimg.ilk = #image then
  146.     if lvl > 127 then
  147.       nuimg = srcimg.duplicate()
  148.       nuimg.copyPixels(nuimg, nuimg.rect, nuimg.rect, [#ink: 33])
  149.       mm = srcimg.duplicate()
  150.       mm.copyPixels(nuimg, nuimg.rect, nuimg.rect, [#blendLevel: lvl - 127])
  151.     else
  152.       nuimg = srcimg.duplicate()
  153.       mm = srcimg.duplicate()
  154.       mm.copyPixels(desaturate(nuimg, 255), nuimg.rect, nuimg.rect, [#blendLevel: 255 - (lvl * 2)])
  155.     end if
  156.     return mm
  157.   else
  158.     return 0
  159.   end if
  160. end
  161.  
  162. on desaturate srcimg, percblend
  163.   if srcimg.ilk = #image then
  164.     bl = 255 - percblend
  165.     new_image = image(srcimg.width, srcimg.height, 8, #grayscale)
  166.     new_image.copyPixels(srcimg, srcimg.rect, srcimg.rect)
  167.     mm = image(srcimg.width, srcimg.height, 32)
  168.     mm.copyPixels(srcimg, srcimg.rect, srcimg.rect)
  169.     mm.copyPixels(new_image, srcimg.rect, srcimg.rect, [#blendLevel: percblend])
  170.     return mm
  171.   else
  172.     return 0
  173.   end if
  174. end
  175.  
  176. on sketch Img, treshold
  177.   w = Img.width
  178.   h = Img.height
  179.   R = rect(0, 0, w, h)
  180.   iimg = image(w, h, 32)
  181.   iimg.copyPixels(Img, R, R)
  182.   if Img.useAlpha = 1 then
  183.     nu = Img.duplicate()
  184.     imgg = Img.createMatte(treshold)
  185.     nuu = Img.duplicate()
  186.     nuu.useAlpha = 0
  187.     bw = image(w, h, 8, #grayscale)
  188.     bw.copyPixels(black, R, R, [#maskImage: imgg])
  189.     white = bw
  190.   else
  191.     nu = image(w, h, 8, #grayscale)
  192.     black = image(w, h, 32)
  193.     white = image(w, h, 32)
  194.     black.fill(0, 0, w, h, rgb(0, 0, 0))
  195.     white.fill(0, 0, w, h, rgb(255, 255, 255))
  196.     nu.copyPixels(iimg, R, R)
  197.     iimg.setAlpha(nu)
  198.     iimg.useAlpha = 1
  199.     img2 = iimg.createMatte(treshold)
  200.     white.copyPixels(black, R, R, [#maskImage: img2])
  201.   end if
  202.   return white
  203. end
  204.  
  205. on fastsketch Img, treshold
  206.   w = Img.width
  207.   h = Img.height
  208.   R = rect(0, 0, w, h)
  209.   iimg = image(w, h, 32)
  210.   iimg.copyPixels(Img, R, R)
  211.   nu = image(w, h, 8, #grayscale)
  212.   blk = black.duplicate()
  213.   whi = image(w, h, 32)
  214.   nu.copyPixels(iimg, R, R)
  215.   iimg.setAlpha(nu)
  216.   iimg.useAlpha = 1
  217.   img2 = iimg.createMatte(treshold)
  218.   whi.copyPixels(blk, R, R, [#maskImage: img2])
  219.   return whi
  220. end
  221.  
  222. on makealpha Img
  223.   w = Img.width
  224.   h = Img.height
  225.   R = rect(0, 0, w, h)
  226.   iimg = image(w, h, 32)
  227.   iimg.copyPixels(Img, R, R)
  228.   nu = image(w, h, 8, #grayscale)
  229.   nu.copyPixels(iimg, R, R)
  230.   iimg.setAlpha(nu)
  231.   iimg.useAlpha = 1
  232.   return iimg
  233. end
  234.  
  235. on createalpha Img
  236.   w = Img.width
  237.   h = Img.height
  238.   R = rect(0, 0, w, h)
  239.   nu = image(w, h, 8, #grayscale)
  240.   nu.copyPixels(Img, R, R)
  241.   return nu
  242. end
  243.  
  244. on addAlpha imgg, alp
  245.   w = imgg.width
  246.   h = imgg.height
  247.   R = rect(0, 0, w, h)
  248.   Img = image(w, h, 32)
  249.   Img.copyPixels(imgg, R, R)
  250.   Img.setAlpha(alp)
  251.   Img.useAlpha = 1
  252.   return Img
  253. end
  254.  
  255. on lumakey imgg, perc
  256.   w = imgg.width
  257.   h = imgg.height
  258.   d = imgg.depth
  259.   R = rect(0, 0, w, h)
  260.   if imgg.useAlpha = 1 then
  261.     nu = image(w, h, d)
  262.     nuu = imgg.duplicate()
  263.     bw = createMatte(nuu, perc)
  264.     bww = image(w, h, 8, #grayscale)
  265.     bww.copyPixels(black, R, R, [#maskImage: bw])
  266.     nuu.useAlpha = 0
  267.     nu.copyPixels(nuu, R, R)
  268.     nu.setAlpha(bww)
  269.     nu.useAlpha = 1
  270.   else
  271.     msk = fastsketch(imgg, perc)
  272.     imggg = image(w, h, 8, #grayscale)
  273.     imggg.copyPixels(msk, R, R)
  274.     nu = addAlpha(imgg, imggg)
  275.   end if
  276.   return nu
  277. end
  278.  
  279. on lightness srcimg, someLevel
  280.   someLevel = (someLevel - 127) / 1.27000000000000002
  281.   Img = srcimg.duplicate()
  282.   over = Img.duplicate()
  283.   if someLevel < 0 then
  284.     over.fill(over.rect, rgb(0, 0, 0))
  285.   else
  286.     over.fill(over.rect, rgb(255, 255, 255))
  287.   end if
  288.   someLevel = abs(someLevel)
  289.   Img.copyPixels(over, srcimg.rect, srcimg.rect, [#blend: someLevel])
  290.   return Img
  291. end
  292.